import * as echarts from '../../plugin/ec-canvas/echarts';
// pages/login/login.js
//获取应用实例
const app = getApp()
const util = require('../../../utils/util.js')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    loadding : 1 ,
    curTime:'xxxx-xx-xx xx:xx:xx',
  },
  onLoad: function(options) {
    var checkpointId = options.checkpointId ; 
    var dateTime = options.curTime ;
    var dutyWeekDeductionDetailList = []
    wx.request({
      url: app.backstageUrl + '/WeChat/Statistics/getDutyWeekDeductionDetail',
      method: 'GET',
      data: {
        checkpointId : parseInt(checkpointId) ,
        departmentId : parseInt(app.globalData.departmentId) ,
        dateTime : dateTime
      },
      dataType: 'json',
      success: (res) => {
        console.log(res)
        let photoes = []
        res.data.getDutyWeekDeductionDetailList.forEach((item,index) => {
          if(item.photo == ""){
            dutyWeekDeductionDetailList.push({
              realname: item.realname ,
              dateTime : item.createTime ,
              address : item.address ,
              category : item.category ,
              content: item.content ,
              deduction : item.deduction ,
              item : item.item ,
              photo : '' ,
              video: item.video,
              videoSrc: app.imageUrl + item.video
            })
          }else if(item.photo.split(",")){
            for (let i = 0; i < item.photo.split(',').length; i++) {
              photoes.push(item.photo.split(',')[i])
            }
            dutyWeekDeductionDetailList.push({
              realname: item.realname ,
              dateTime : item.createTime ,
              address : item.address ,
              category : item.category ,
              content: item.content ,
              deduction : item.deduction ,
              item : item.item ,
              photo : item.photo.split(',')[0] ,
              photoLength: item.photo.split(',').length,
              video: item.video,
              videoSrc: app.imageUrl + item.video
            })
          }else{
            photoes.push(item.photo)
            dutyWeekDeductionDetailList.push({
              realname: item.realname ,
              dateTime : item.createTime ,
              address : item.address ,
              category : item.category ,
              content: item.content ,
              deduction : item.deduction ,
              item : item.item ,
              photo : item.photo,
              photoLength: 1,
              video: item.video,
              videoSrc: app.imageUrl + item.video
            })
          }
        });
        this.setData({
          loadding : 0 ,
          curTime: dateTime ,
          photoes : photoes ,
          dutyWeekDeductionDetailList:dutyWeekDeductionDetailList
        })
      }
    })
  },

  previewImage: function (e) {
    console.log(e)
    wx.previewImage({
      current: e.target.dataset.src, // 当前显示图片的http链接
      urls: this.data.photoes // 需要预览的图片http链接列表
    })
},
  


  
 
})

